//
//  ShopTabBarController.m
//  jinwang
//
//  Created by jzb on 2018/3/23.
//  Copyright © 2018年 jzb. All rights reserved.
//

#import "ShopTabBarController.h"
#import "BaseNavigationC.h"
//商城
#import "JWShopHomeVC.h"
#import "JWShopAdvisoryVC.h"
#import "JWShopShoppingCartVC.h"
#import "JWShopMeVC.h"

@interface ShopTabBarController ()

@end

@implementation ShopTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.translucent = NO;
    
    
    
        
        JWShopHomeVC *JWShopHome_VC = [[JWShopHomeVC alloc]init];
        JWShopAdvisoryVC *JWShopAdvisory_VC = [[JWShopAdvisoryVC alloc]init];
        JWShopShoppingCartVC *JWShopShoppingCart_VC = [[JWShopShoppingCartVC alloc]init];
        JWShopMeVC *JWShopMe_VC = [[JWShopMeVC alloc]init];
        
        JWShopHome_VC.isFirstClass = YES;
        JWShopAdvisory_VC.isFirstClass = YES;
        JWShopShoppingCart_VC.isFirstClass = YES;
        JWShopMe_VC.isFirstClass = YES;
        
        [self addChildVC:JWShopHome_VC title:@"首页" image:@"jw_shop_homeIcon" selectedImage:@"jw_shop_homeIcon_sel"];
        [self addChildVC:JWShopAdvisory_VC title:@"资讯" image:@"jw_shop_zixunIcon" selectedImage:@"jw_shop_zixunIcon_sel"];
        [self addChildVC:JWShopShoppingCart_VC title:@"购物车" image:@"jw_shop_gouwucheIcon" selectedImage:@"jw_shop_gouwucheIcon_sel"];
        [self addChildVC:JWShopMe_VC title:@"个人中心" image:@"jw_shop_meIcon" selectedImage:@"jw_shop_meIcon_sel"];
        
    
    
}

/**
 *  添加一个子控制器
 *  @param childVC       子控制器
 *  @param title         标题
 *  @param image         图片
 *  @param selectedImage 选中的图片
 */
- (void)addChildVC:(UIViewController *)childVC title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
    // 设置子控制器的文字(可以设置tabBar和navigationBar的文字)
    childVC.title = title;
    
    // 设置子控制器的tabBarItem图片
    childVC.tabBarItem.image = [[UIImage imageNamed:image]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 禁用图片渲染
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    // 设置文字的样式
    [childVC.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName : kRGBColor(36, 36, 36)} forState:UIControlStateNormal];
    [childVC.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName : UIColorHex(0xEEA72B)} forState:UIControlStateSelected];
    
    // 为子控制器包装导航控制器
    BaseNavigationC *navi = [[BaseNavigationC alloc] initWithRootViewController:childVC];
    navi.navigationBar.barTintColor = UIColorHex(0xEEA72B);// 设置导航栏背景颜色  #EEA72B
    //    navi.navigationBar.barTintColor = [UIColor blackColor];// 设置导航栏背景颜色
    
    [navi.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:18],
       NSForegroundColorAttributeName:[UIColor whiteColor]}];// 设置导航栏文字字体大小 文字的颜色
    // 添加子控制器
    [self addChildViewController:navi];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
